<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>疫苗固有信息管理</title>
	<meta name="decorator" content="default"/>
	<script src="${ctxStatic}/common/change/change.js"></script>
	<script type="text/javascript">
		var bsVaccineInfo = JSON.parse('${fns:toJson(bsVaccineInfo)}');
		
		$(document).ready(function() {
			initVaccNameInfo(bsVaccineInfo.companyCode,bsVaccineInfo.vaccineId);
			initVaccCompanyName(bsVaccineInfo.companyCode);
			initDose(bsVaccineInfo.dose);
			$(".vaccineCompany").change(function(){
				var vaccId = $(this).val();
				initCompanyNameInfo($(this).val());
				if(vaccId == ""){
					initVaccCompanyName("");
				}
			});
			$(".vaccineDose").change(function(){
				initDose($(this).val());
			});
		});
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
        
        function initDose(defaultvalue){
			var select = "<option value=''>--请选择--</option>";
			var url = "${ctx}/vaccinate/bsVaccineInfo/getByDose";
			$.ajax({
				url : url,	
				success : function(data){
					data = $.parseJSON(data);
					for(var i = 0;i < data.length; i++){
						select += "<option value='"+data[i].dose+"'>"+data[i].dose+"</option>";
					};
					$("select").each(function() {
						if ($(this).hasClass("vaccineDose")) {
							$(this).html(select);
							if (defaultvalue) {
								$(this).val(defaultvalue);
							}
							$(this).select2();
						}
					});
				}
			});
		}
		
		function union(vid,vaccineId,vaccineName,vaccNameAll,type,companyName,spec,doseType,dose,containerTypeNam,customBillNo,largePackage){
			debugger;
			if(vaccineId == '' || vaccineId == '-'){
				layer.msg("疫苗code不能为空");
				return;
			}
			if(vaccineName == '' || vaccineName == '-'){
				layer.msg("疫苗名称不能为空");
				return;
			}
			if(type == '' || type == '-'){
				layer.msg("疫苗类型不能为空");
				return;
			}
			if(companyName == '' || companyName == '-'){
				layer.msg("生产企业不能为空");
				return;
			}
			if(spec == '' || spec == '-'){
				layer.msg("规格不能为空");
				return;
			}
			if(doseType == '' || doseType == '-'){
				layer.msg("剂型不能为空");
				return;
			}
			if(dose == '' || dose == '-'){
				layer.msg("剂量不能为空");
				return;
			}
			if(containerTypeNam == '' || containerTypeNam == '-'){
				layer.msg("容器类型不能为空");
				return;
			}
			var obj = {
				vid : vid,
				vaccineId : vaccineId,
				vaccName : vaccineName,
				vaccNameAll : vaccNameAll,
				type : type,
				companyName : companyName,
				spec : spec,
				doseType : doseType,
				dose : dose,
				containerTypeNam : containerTypeNam,
				customBillNo : customBillNo,
				largePackage : largePackage
			}
			window.parent.addInfo(obj);
			/* var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index); */
		}
		
		function closeLayer(){
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		}
	</script>
	<style type="text/css">
		body{
		   padding:10px;
		}		
		#contentTable td ,#contentTable th{
			text-align: center;
			padding:1px 10px;
		}
		.minWidth {
			min-width: 180px;
		}
	</style>
</head>
<body>
	<form:form id="searchForm" modelAttribute="bsVaccineInfo" action="${ctx}/vaccinate/bsVaccineInfo/findList" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input id="type" name="type" type="hidden" value="${bsVaccineInfo.type}"/>
		<table class="table table-bordered">
			<tr>
			    <th>疫苗名称:</th>
				<td>
					<form:select path="vaccineId" id="vaccineId" class="span2 minWidth vaccineCompany" >
						<form:option value=""  label="--请选择--"/>
					</form:select>
				</td>
				<th>生产企业：</th>
				<td>
					<form:select path="companyCode" id="companyCode" class="span2 minWidth selectCompany vaccCompanyName">
						<form:option value="" label="--请选择--"/> 
					</form:select>
				</td>
				<th>疫苗剂量：</th>
				<td>
					<form:select path="dose" id="dose" class="span2 minWidth vaccineDose">
						<form:option value="" label="--请选择--"/> 
					</form:select>
				</td>
			</tr>
			<tr>
				<%-- <th>疫苗类型:</th>
				<td>
					<form:select path="type" id="type" class="span2 minWidth" >
						<form:option value="" label="--请选择--"/>
						<form:options items="${fns:getDictList('bs_vaccineInfo_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
				</td> --%>
				<th>疫苗剂型：</th>
				<td>
					<form:select path="doseType" id="doseType" class="span2 minWidth" >
						<form:option value="" label="--请选择--"/>
						<form:options items="${fns:getDictList('bs_vaccineInfo_doseType')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
				</td>
			    <th>容器类型:</th>
				<td colspan = "3">
					<form:select path="containerTypeNam" id="containerTypeNam" class="span2 minWidth" >
						<form:option value="" label="--请选择--"/>
						<form:options items="${fns:getDictList('bs_vaccineInfo_containerType')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
				</td>
			</tr>
		</table>
		<div>
			<button id="btnSubmit" class="btn btn-primary" type="submit">查询</button>
			<button class="btn btn-primary" onclick="closeLayer()" type="button">关闭窗口</button>
		</div>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>操作</th>
				<th>疫苗编码</th>
				<th>疫苗名称</th>
				<th>疫苗类型</th>
				<th>生产企业</th>
				<th>规格</th>
				<th>剂型</th>
				<th>剂量</th>
				<th>容器类型</th>
				<th>批准文号</th>
				<th>大包装(支(粒)/箱)</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="bsVaccineInfo">
			<tr>
				<td>
				<button type="button" style="border: none; background-color: #ffffff;"
					onclick="union('${bsVaccineInfo.id}',
					'${bsVaccineInfo.vaccineId}',
					'${bsVaccineInfo.vaccineName}',
					'${bsVaccineInfo.vaccNameAll}',
					'${bsVaccineInfo.type}',
					'${bsVaccineInfo.companyName}',
					'${bsVaccineInfo.spec}',
					'${bsVaccineInfo.doseType}',
					'${bsVaccineInfo.dose}',
					'${bsVaccineInfo.containerTypeNam}',
					'${bsVaccineInfo.customBillNo}',
					'${bsVaccineInfo.largePackage}')">关联</button>
				</td>
				<td>${bsVaccineInfo.vaccineId}</td>
				<td>${bsVaccineInfo.vaccineName}</td>
				<td>${fns:getDictLabel(bsVaccineInfo.type,'bs_vaccine_type','')}</td>
				<td>${bsVaccineInfo.companyName}</td>
				<td>${bsVaccineInfo.spec}</td>
				<td>${fns:getDictLabel(bsVaccineInfo.doseType,'bs_vaccineInfo_doseType','')}</td>
				<td>${bsVaccineInfo.dose}</td>
				<td>${fns:getDictLabel(bsVaccineInfo.containerTypeNam,'bs_vaccineInfo_containerType','')}</td>
				<td>${bsVaccineInfo.customBillNo}</td>
				<td>${bsVaccineInfo.largePackage}</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>